import { cacheableRouter } from "@chulei-ui/components";
import type { RoutePath } from "@chulei-ui/components";

export const 首页: RoutePath = {
  path: "home",
  meta: {
    name: "首页",
  },
  component: () => import("./../src/pages/home/Home.vue"),
};

export const 引导页: RoutePath = {
  path: "/bootstrap",
  meta: {
    name: "引导",
  },
  component: () => import("./../src/pages/bootstrap/Bootstrap.vue"),
};

export const 合同: RoutePath = {
  path: "contracts",
  meta: {
    name: "合同",
  },
  component: () => import("./../src/pages/contracts/ContractTable.vue"),
};

export const 星域市场: RoutePath = {
  path: "market",
  meta: {
    name: "星域市场",
  },
  component: () => import("./../src/pages/market/MarketTree.vue"),
};

export const 蓝图制造: RoutePath = {
  path: "blueprints",
  meta: {
    name: "蓝图制造",
  },
  component: () => import("./../src/pages/blueprint/BlueprintTree.vue"),
};

export const 个人资产: RoutePath = {
  path: "assets",
  meta: {
    name: "个人资产",
  },
  component: () => import("./../src/pages/assets/asserts-index.vue"),
};

export const 行星开发: RoutePath = cacheableRouter(
  {
    path: "plants",
    meta: {
      name: "行星开发",
    },
  },
  import("./../src/pages/plants/plant-index.vue"),
  [{ path: "details", meta: { name: "详情" }, component: () => import("./../src/pages/plants/planet-details.vue") }]
);
export const 我的: RoutePath = {
  path: "my",
  meta: {
    name: "我的",
  },
  children: [行星开发],
};
// const cacheableRouter = (
//   config: Omit<RoutePath, "component" | "children">,
//   lazyComponent: Promise<{ default: { name: string } }>,
//   children?: RoutePath[]
// ): RoutePath => {
//   const route: RoutePath = {
//     ...config,
//     children,
//     component: async () => {
//       const module = await lazyComponent;
//       if (config.meta?.keepAlive) {
//         ROUTER_NAME_MAP.set(route.meta!.simple!.path, module.default.name);
//       }
//       return module;
//     },
//   } as RoutePath;
//   return route;
// };

// export const 首页: RoutePath = {
//   path: "war",
//   meta: {
//     name: "联赛对阵",
//   },
//   component: () => import("./../src/pages/league/war-index-page.vue"),
//   children: [
//     {
//       path: "leagues",
//       meta: {
//         name: "联赛对阵明细",
//       },
//       component: () => import("./../src/pages/league/war-details.vue"),
//     },
//   ],
// };
